package com.hzdl.car.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzdl.car.bean.BaseStat;
import com.hzdl.car.bean.Customer;
import com.hzdl.car.bean.News;
import com.hzdl.car.mapper.CustomerMapper;
import com.hzdl.car.service.CustomerService;
import com.hzdl.car.vo.CustomerVo;
import com.hzdl.car.vo.NewsVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Transactional
@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerMapper customerMapper;
    @Override
    public PageInfo<Customer> findCustomer(CustomerVo customerVo) {
        PageHelper.startPage(customerVo.getPage(),customerVo.getLimit());
        List<Customer> list=customerMapper.findCustomer(customerVo);
        PageInfo<Customer> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int delCustomer(CustomerVo customerVo) {
        return customerMapper.delCustomer(customerVo);
    }

    @Override
    public int customerDelChk(String[] ids) {
        int row=0;
        for (String i:ids){
            CustomerVo customerVo=new CustomerVo();
            customerVo.setIdentity(i);
            row+=customerMapper.delCustomer(customerVo);
        }
        return row;
    }

    @Override
    public int addCustomer(CustomerVo customerVo) {
        return customerMapper.addCustomer(customerVo);
    }

    @Override
    public int updateCustomer(CustomerVo customerVo) {
        return customerMapper.updateCustomer(customerVo);
    }

    @Override
    public List<Customer> findCustomerById(String id) {
        return customerMapper.findCustomerById(id);
    }

    @Override
    public List<BaseStat> findCustomerAddress() {
        return customerMapper.findCustomerAddress();
    }

    @Override
    public List<Customer> findCustomerExcel(CustomerVo customerVo) {
        return customerMapper.findCustomer(customerVo);
    }
}
